from django.contrib import admin
from .models import Area, AreaImage


class ImageInline(admin.TabularInline):
    model = AreaImage
    extra = 1


@admin.register(Area)
class AreaAdmin(admin.ModelAdmin):
    list_display = ('title', 'category', 'description')
    search_fields = ('title', 'description', 'category')
    list_filter = ('category',)
    inlines = [ImageInline]  # 允许在内容管理页面中直接管理图片


@admin.register(AreaImage)
class CategoryAdmin(admin.ModelAdmin):
    list_display = ('name', 'file', 'created_at')
    search_fields = ('name',)
